<?php
	
class MusicCatModel extends Model{		
	
	public function getMusicCatList(){
		$sql	=	"select * from baby_music_cat order by sort asc";
		return  $this->query($sql);
	}
	
	/* get cat information */
	public function getThemeInfo($cat_id){}
	
	/* get audio by cat_id */
	public function getAudioByCatId($cat_id){
		$AudioModel		=	M('Audio');		
		return $AudioModel->field(" baby_audio.name,baby_audio.filesize,baby_audio.timelength,a1.invalid, baby_audio.ctime,a1.id, a2.name cat_name,a1.sort ")
						  ->join(" baby_music a1 on a1.audio_id = baby_audio.id ")
						  ->join(" baby_music_cat a2 on a2.id = a1.cat_id ")->where("a1.cat_id = '{$cat_id}'")->order("a1.sort asc")->select();
	}
	
	public function getAudioInfo($id){
		$AudioModel		=	M('Audio');	
		return $AudioModel->field(" baby_audio.id audio_id,baby_audio.name,baby_audio.filesize,baby_audio.timelength,baby_audio.audio_url,a1.invalid, baby_audio.ctime,a1.id music_id,a1.cat_id, a2.name cat_name,a1.sort ")
						  ->join(" baby_music a1 on a1.audio_id = baby_audio.id ")
						  ->join(" baby_music_cat a2 on a2.id = a1.cat_id ")->where("a1.id = '{$id}'")->order("a1.sort asc")->find();
	}
	
}

?>